package com.donfu.web.controller.house;

import java.util.List;

import com.donfu.common.utils.poi.ExcelUtil;
import com.donfu.system.domain.house.HouseNoveltyType;
import com.donfu.system.service.house.IHouseNoveltyTypeService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.donfu.common.annotation.Log;
import com.donfu.common.core.controller.BaseController;
import com.donfu.common.core.domain.AjaxResult;
import com.donfu.common.enums.BusinessType;
import com.donfu.common.core.page.TableDataInfo;

/**
 * 品牌类型Controller
 * 
 * @author donfu
 * @date 2021-12-07
 */
@RestController
@RequestMapping("/house/NoveltyType")
public class HouseNoveltyTypeController extends BaseController
{
    @Autowired
    private IHouseNoveltyTypeService houseNoveltyTypeService;

    /**
     * 查询品牌类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(HouseNoveltyType houseNoveltyType)
    {
        startPage();
        List<HouseNoveltyType> list = houseNoveltyTypeService.selectHouseNoveltyTypeList(houseNoveltyType);
        return getDataTable(list);
    }

    /**
     * 导出品牌类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:type:export')")
    @Log(title = "品牌类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HouseNoveltyType houseNoveltyType)
    {
        List<HouseNoveltyType> list = houseNoveltyTypeService.selectHouseNoveltyTypeList(houseNoveltyType);
        ExcelUtil<HouseNoveltyType> util = new ExcelUtil<HouseNoveltyType>(HouseNoveltyType.class);
        return util.exportExcel(list, "品牌类型数据");
    }

    /**
     * 获取品牌类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:type:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(houseNoveltyTypeService.selectHouseNoveltyTypeById(id));
    }

    /**
     * 新增品牌类型
     */
    @PreAuthorize("@ss.hasPermi('system:type:add')")
    @Log(title = "品牌类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HouseNoveltyType houseNoveltyType)
    {
        return toAjax(houseNoveltyTypeService.insertHouseNoveltyType(houseNoveltyType));
    }

    /**
     * 修改品牌类型
     */
    @PreAuthorize("@ss.hasPermi('system:type:edit')")
    @Log(title = "品牌类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HouseNoveltyType houseNoveltyType)
    {
        return toAjax(houseNoveltyTypeService.updateHouseNoveltyType(houseNoveltyType));
    }

    /**
     * 删除品牌类型
     */
    @PreAuthorize("@ss.hasPermi('system:type:remove')")
    @Log(title = "品牌类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(houseNoveltyTypeService.deleteHouseNoveltyTypeByIds(ids));
    }
}
